package tec;

public class TestPassagerStandard extends TestPassagerAbstrait{

	public class TransportAnon implements Transport {
		public void allerArretSuivant() throws TecInvalidException {
			return;
		}
    	public boolean aPlaceAssise() {
    		return true;
    	}
    	public boolean aPlaceDebout() {
    		return true;
    	}
	}
	
	protected PassagerAbstrait creerPassager(String nom, int destination)
	{
		return new PassagerStandard(nom, destination);
	}
	
	public void lancer() throws TecInvalidException
	{
		type_s = new String("Standard");
		super.lancer();
		System.out.print("."); super.nbTest++;
		testNouvelArret();
		System.out.print("."); nbTest++;
		testMonterDans();
		System.out.println("OK (" + super.nbTest + ")");
	}
	protected void testNouvelArret() {
		Passager test1 = new PassagerStandard("Testeur", 5);
		test1.accepterPlaceDebout();
		
		Bus bus = new FauxBus();
		test1.nouvelArret(bus, 4);
		
		assert 0 == ((FauxBus)bus).messages.size() : "pas a destination";
		
		test1.nouvelArret(bus, 5);
		assert "demande sortie" == ((FauxBus)bus).messages.getLast() : "destination";   

	}
	
	protected void testMonterDans() {
		PassagerStandard test1 = new PassagerStandard("Testeur", 5);
		Bus bus = new FauxBus();
		Transport bus2 = new TransportAnon();
		boolean test = true;
		try {
			test1.monterDans(bus2);
		} catch(TecInvalidException t) {
			test = false;
		}

		assert test == false : "Erreur de capture d'exception";
 

	}
}
